<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec"    uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body class="ms-theme-blue">

  <%@ include file="/WEB-INF/include/header.jsp"%>
  <%@ include file="/WEB-INF/include/submenu.jsp"%>
  
  <div class="container-fluid ms-container has-ms-sidemenu">
    
    <ol class="ms-breadcrumb breadcrumb">
      <li class="active">生成派车单&nbsp;-&nbsp;</li>
    </ol>
    
    <div class="ms-content-layout">
    
      <div class="block-heading">
         <h5>派车单信息</h5>
      </div>
      
     <form class="form-horizontal ms-form form-personal-info" method="POST" action="${ctx.host}/shipment-lines/${loadNumber}/generate" 
           data-validate="true" data-redirect="${ctx.host}/shipment-lines?${sessionScope.generateQueryString}">
        <input type="hidden" name="target" value="${target}">
        <input type="hidden" name="id" value="${dispatchOrder.id}" >
        <input type="hidden" name="code" value="${dispatchOrder.code}" >
        <input type="hidden" name="organizationId" value="${dispatchOrder.organizationId}">
        <input type="hidden" name="creatorId" value="${currentPrincipal.id}" >
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">调度指令组号：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"> ${dispatchOrder.shipmentGroupId}</p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">起始地：</label>
          <div class="col-xs-3 ">
            <p class ="form-control-static">
              ${empty dispatchOrder.startFacilityId ? '' : ( persist.loadPlace(dispatchOrder.startFacilityId).code ).concat( '-' ).concat( persist.loadPlace(dispatchOrder.startFacilityId).name )}
            </p>
          </div>
          <label class="col-xs-2 control-label">目的地：</label>
           <div class="col-xs-3 ">
             <p class ="form-control-static">
               ${empty dispatchOrder.destinationFacilityId ? '' : (persist.loadPlace(dispatchOrder.destinationFacilityId).code).concat('-').concat(persist.loadPlace(dispatchOrder.destinationFacilityId).name)}
             </p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">驳运车号：</label>
          <div class="col-xs-3">
            <p class ="form-control-static">
               ${empty dispatchOrder.vehicleId ? '' : (persist.vehicle(dispatchOrder.vehicleId).name).concat('-').concat(persist.vehicle(dispatchOrder.vehicleId).code)}
            </p>
          </div>
          <label class="col-xs-2 control-label">行驶公里数：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${dispatchOrder.facilityDistance}" minFractionDigits="2"/> </p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">主驾驶员：</label>
          <div class="col-xs-3 modal-search-warp">
            <input type="text" data-validate="required" name="mainDriver"  autocomplete="off" tabindex="1" data-org="organizationId" value="${empty dispatchOrder.mainDriverId ? '' : (persist.employee(dispatchOrder.mainDriverId).code).concat('-').concat(persist.employee(dispatchOrder.mainDriverId).name)}"
                              class="form-control eId-search modal-search" data-value-name="mainDriverId" 
                              placeholder="请填写主驾驶员"  data-modal-search="#modal-search-eId">
                        <input type="hidden" name="mainDriverId" value="${dispatchOrder.mainDriverId}">
            <a href="javascript:void(0);" class="btn"  data-koala-search="true" data-target="#modal-search-eId" data-toggle="modal">
              <span class="glyphicon glyphicon-align-justify" aria-hidden="true"></span>
            </a>
          </div>
          
          <label class="col-xs-2 control-label">第一副驾驶员：</label>
          <div class="col-xs-3 modal-search-warp">
            <input type="text" name="firstViceDriver" autocomplete="off" tabindex="2" data-org="organizationId" value="${empty dispatchOrder.firstViceDriverId ? '' : (persist.employee(dispatchOrder.firstViceDriverId).code).concat('-').concat(persist.employee(dispatchOrder.firstViceDriverId).name)}"
                               class="form-control fId-search modal-search" data-value-name="firstViceDriverId"
                                placeholder="请填写第一副驾驶员"  data-modal-search="#modal-search-fId">
            <input type="hidden" name="firstViceDriverId" value="${dispatchOrder.firstViceDriverId}">
            <a href="javascript:void(0);" class="btn" data-koala-search="true" data-target="#modal-search-fId" data-toggle="modal">
              <span class="glyphicon glyphicon-align-justify" aria-hidden="true"></span>
            </a>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">装载能力：</label>
          <div class="col-xs-3">
            <input type="text" name="fullLoadNumber" data-validate="number|min,1" class="form-control " placeholder="" value="${dispatchOrder.fullLoadNumber}" tabindex="3" autocomplete="off">
          </div>
          
          <label class="col-xs-2 control-label">加油类型：</label>
          <div class="col-xs-3">
             <select class="select2 form-control" name="oilTypeId" tabindex="4" data-validate="required">
              <option></option>
                <c:forEach items="${enums['OilType']}" var="oilType">
                  <option value="${oilType.id}" ${defaultOilTypeId == oilType.id ? 'selected' : ''}>${oilType.description}</option>
                </c:forEach>
             </select>
           </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">备注：</label>
          <div class="col-xs-8">
            <textarea name="remarks" rows="5" style="width: 80%;" tabindex="24">${dispatchOrder.remarks}</textarea>
          </div>
        </div>

        <div class="block-heading">
          <h5>商品车明细列表</h5>
          <h5 style="margin-left: 70%;">调度数量：${shipmentLine.loadQuantity}</h5>
        </div>
         
        <c:forEach items="${shipmentOrders}" var="order">
          
          <div class="form-horizontal ms-form form-personal-info">
        
            <div class="form-group ms-form-group">
              <div class="col-xs-2">
                <p class ="form-control-static">订单号：${order.code}</p>
              </div>
              <div class="col-xs-2">
                <p class ="form-control-static">客户：${order.client}</p>
              </div>
              <div class="col-xs-2 ">
                <p class ="form-control-static">订单起始地：${order.startFacility}</p>
              </div>
              <div class="col-xs-2 ">
                <p class ="form-control-static">订单目的地：${order.endFacility}</p>
              </div>
              <div class="col-xs-2">
                <p class ="form-control-static">结算公里数：<fmt:formatNumber value="${order.kilometer}" minFractionDigits="2"/> </p>
              </div>
              <div class="col-xs-2">
                <p class ="form-control-static">单价：<fmt:formatNumber value="${order.contractRate}" minFractionDigits="2"/> </p>
              </div>
            </div>
        
          </div>
        
          <table class="table table-hover ms-table">
            <thead>
              <tr>
                <th>VIN码</th>
                <th>数量</th>
                <th>车型</th>
                <th>颜色</th>
                <th>运输方式</th>
                <th>装车道号</th>
                <th>制造商</th>
                <th>起始地</th>
                <th>目的地</th>
                <th>目的地地址</th>
                <th>目的地联系电话</th>
                <th>预计装运时间</th>
                <th>预计起运时间</th>
              </tr>
            </thead>
            <tbody>
              <c:forEach items="${order.shipmentOrderItems}" var="item">
                <tr>
                  <td>${item.vinCode}</td>
                  <td>${item.quantity}</td>
                  <td>${item.carType}</td>
                  <td>${item.carColor}</td>
                  <td>${item.transType}</td>
                  <td>${item.driveWay}</td>
                  <td>${item.manufactor}</td>
                  <td>${item.startFacility}</td>
                  <td>${item.endFacility}</td>
                  <td>${item.destinationAddress}</td>
                  <td>${item.destinationTelecomNumber}</td>
                  <td>${item.loadDate}</td>
                  <td>${item.deptDate}</td>
                </tr>
              </c:forEach>
            </tbody>
          </table>

        </c:forEach>

        <div class="form-group ms-form-group">
          <div class="col-xs-6 col-xs-offset-3 ms-operation-group top-margin-20 text-center">
            <div class="col-xs-5">
              <button type="reset" class="btn btn-block btn-default">重置</button>
            </div>
            <div class="col-xs-5">
              <button type="submit" class="btn btn-block btn-primary">提交</button>
            </div>
          </div>
        </div>

      </form>
    
    </div> 
  </div>       
  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource type="script" root="${ctx.resource}/build" src="js/page/business/shipment/shipment-generate-prepare.js" />
  <script type="text/javascript">
    require(['page/business/shipment/shipment-generate-prepare'], function(page) {
      page.init({
        actualLoadNumber: '${shipmentLine.loadQuantity}'
      })
    })
  </script>

</body>
</html>